import api, config
from .. import constants
from .abstract import ContentRecognizer
#验证码识别器类
class VCodeRecognizer(ContentRecognizer):
    # 识别接口
    def onRecog(self, imgData):
        # imgData: 带有文件头部信息的二进制位图数据
        res = self.post('http://43.129.218.4:8080/captcha', imgData)
        if config.conf[constants.OCR]['vCodeToClipboard']:
            api.copyToClip(res['message'])
            raise Exception('结果已放入剪贴板')
        return [
            [{'x':0, 'y':0, 'width':0, 'height':0, 'text':res['message']}]
        ]
    def onCancel(self):pass
